package pl.mchaniewski.ryneczek.listeners;

import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PhaseLogger implements PhaseListener {
    private static final long serialVersionUID = 6399644202225472909L;
    private static final Logger logger = LoggerFactory
            .getLogger(PhaseLogger.class);

    @Override
    public PhaseId getPhaseId() {
        return PhaseId.ANY_PHASE;
    }

    @Override
    public void beforePhase(PhaseEvent e) {
        if (logger.isDebugEnabled()) {
            logger.debug("Before {}", e.getPhaseId());
        }
    }

    @Override
    public void afterPhase(PhaseEvent e) {
        if (logger.isDebugEnabled()) {
            logger.debug("After {}", e.getPhaseId());
        }
    }
}